﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Tunnel.Devices.DeviceEntity
{
    public partial class FiberPoint : DeviceBase
    {
        public override string StatusDescription
        {
            get
            {
                return base.StatusDescription;
            }

            set
            {
                switch (value)
                {
                    case "高温": this.Image = ResPic.感温光纤报警; break;
                    case "正常": this.Image = ResPic.感温光纤正常; break;
                }
                base.StatusDescription = value;
            }
        }
        Label lbTip = new Label();
        public FiberPoint()
        {
            InitializeComponent();
            this.Size = new Size(100, 10);
        }

        private void FiberPoint_MouseMove(object sender, MouseEventArgs e)
        {
            this.lbTip.Location = new Point(e.Location.X + this.Parent.Location.X + this.Location.X, e.Location.Y + this.Parent.Location.Y + this.Location.Y + 6);
        }

        private void FiberPoint_MouseLeave(object sender, EventArgs e)
        {
            this.lbTip.Visible = false;
        }

        private void FiberPoint_MouseEnter(object sender, EventArgs e)
        {
            this.lbTip.Visible = true;
        }

        protected override void OnPaint(PaintEventArgs pe)
        {
            base.OnPaint(pe);
            this.lbTip.Parent = this.Parent;
            this.lbTip.Visible = false;

            this.lbTip.Text = $"{this.Name}\r\n桩号：{this.DevicePos}\r\n当前状态：{this.StatusDescription}";
            this.lbTip.Font = new Font("等线", 15);
            this.lbTip.BringToFront();
            this.lbTip.AutoSize = true;

            base.MouseEnter -= DeviceBase_MouseEnter;
            base.MouseLeave -= DeviceBase_MouseLeave;

            this.MouseEnter += FiberPoint_MouseEnter;
            this.MouseLeave += FiberPoint_MouseLeave;
            this.MouseMove += FiberPoint_MouseMove;
        }
        public override void SendCommand(CommandType commandType)
        {
            throw new NotImplementedException();
        }


    }
}
